package com.shopping.service.impl;

import java.util.List;

import com.shopping.dao.IBaseDao;
import com.shopping.service.IBaseService;
/**
 * 基础业务实现类，在子类使用时需要传入Model和Dao
 * @author 吴飞
 *
 * @param <T>
 */

public abstract class BaseServiceImpl<T> implements IBaseService<T>{
	

	private IBaseDao<T> baseDao;
	public abstract IBaseDao<T> getBaseDao();

	@Override
	public List<T> findAll() {
		return this.getBaseDao().selectAll();
	}

	@Override
	public List<T> findByPage(Integer offset, Integer rows) {
		return this.getBaseDao().selectByPage(offset, rows);
	}

	@Override
	public T findById(Integer id) {
		return this.getBaseDao().selectById(id);
	}
	
	@Override
	public Integer add(T entity) {
		return this.getBaseDao().insert(entity);
	}

	@Override
	public Integer deleteById(Integer id) {
		return this.getBaseDao().deleteById(id);
	}

	@Override
	public Integer edit(T entity) {
		return this.getBaseDao().update(entity);
	}

}
